home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 3⁄30⁄90 / 1010-THINK Pascal Convers-Mar90 < prev    next >
Encoding:
Text File  |  1990-03-30  |  2.6 KB  |  75 lines  |  [TEXT/GEOL]

  1. Item    0239174                         30-March-90        11:31PST
  2.  
  3. From:   D5369                           Mgmt Sys Des, Chuck McMath,PRT
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    THINK Pascal Conversion
  8.  
  9. Folks:
  10.  
  11. I received THINK Pascal 3.0 last weekend, and have spent a few days converting
  12. a large program to it from MPW.  The conversion went smoothly for the most
  13. part, thanks to the good instructions in the manual.  However, I did run into
  14. one 'gotcha'.  Take heed:
  15.  
  16.   You may be aware that there is more than one way to indicate conditional
  17. complilation in MacApp:
  18.  
  19.         {$IFC qDebug}
  20.             Writeln('Hey, I am debugging this baby.');
  21.         {$ENDC}
  22.  
  23. is the 'traditional' way.  With MacApp 2.0ß9, you can use another technique (I
  24. first saw this mentioned by Keith Rollin in FrameWorks Vol. 3, No. 3):
  25.  
  26.         IF qDebug THEN
  27.             Writeln('Hey, I am debugging this baby.');
  28.  
  29. The second case works because UMacAppUtilities declares a set of variables
  30. named identically to the debug compile-time switches (look it up if you don't
  31. believe me!).  The MPW compiler does not emit code for the second case if
  32. qDebug is FALSE, because UMacAppUtilities has been compiled and the variable is
  33. set.
  34.  
  35. The problem is that the THINK Pascal compiler doesn't make the same decision --
  36. the value of the MacApp variable qDebug (NOT the compile time switch) is
  37. unknown when you compile your unit.  Therefore, the compiler has to compile the
  38. Writeln in the second case - it just never gets executed.  So what, you say?
  39. Well, if you reference a debugging routine like ReadInteger (which I do) and
  40. try to build a non-MacApp Debugger project (like I did) you will get link
  41. errors (you get the idea).  My particular example:
  42.  
  43.         IF qDebug THEN
  44.             spd := ReadInteger('Enter idle speed (in ticks) :');
  45.  
  46. ReadInteger (MacApp Condensed Reference, p.73) obviously doesn't exist in the
  47. non-MacApp debugger instance, so the Linker could not find it.  The bottom line
  48. is:
  49.  
  50.         to ensure compatibility, use the compile-time switches in your code
  51.  
  52.  
  53. Item 2: THINK Pascal also doesn't like VAR declarations of the form:
  54.  
  55.         CONST
  56.             aNumber =   10;
  57.         VAR
  58.             anArray: ARRAY [0..aNumber-1] OF INTEGER; <-- choke here
  59.  
  60. Rather use this style:
  61.  
  62.         CONST
  63.             aNumber =   10;
  64.             aNumberMinusOne  =   aNumber - 1;
  65.         VAR
  66.             anArray: ARRAY [0..aNumberMinusOne] OF INTEGER;
  67.  
  68. Other than that, the conversion was pretty smooth sailing.  Now if my program
  69. only worked like it was supposed to...
  70.  
  71. Whew!
  72.  
  73. chuck mcmath
  74.  
  75.